package com.org.devg.elasticsearch;

import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author devg
 * @Date 2019/10/13 17:46
 */

@Configuration
@ComponentScan(basePackages = {"com.org.devg.elasticsearch"})
@EnableConfigurationProperties(EsConfig.class)
@ConditionalOnWebApplication //web应用才生效
public class EsAutoConfiguration {

  private final EsConfig esConfig;

  public EsAutoConfiguration(EsConfig esConfig) {
    this.esConfig = esConfig;
  }

  @Bean
  public EsSearch esSearch() {
    EsSearch esSearch = new EsSearch(esConfig);
    return esSearch;
  }

}
